# Contributor: Pavel Pletenev <cpp.create@gmail.com>
# Maintainer: Pavel Pletenev <cpp.create@gmail.com>
pkgname=cryfs
pkgver=0.10.3
pkgrel=1
pkgdesc="Cryptographic filesystem for the cloud"
url="https://github.com/cryfs/cryfs"
# Fails on other arches
arch="x86_64 aarch64"
license="LGPL-3.0-only"
makedepends="cmake attr-dev curl-dev fuse-dev linux-headers
	boost-dev python3"
source="$pkgname-$pkgver.tar.gz::https://github.com/cryfs/cryfs/archive/$pkgver.tar.gz
	0001-fix-for-python3.patch"

prepare() {
	default_prepare
	echo "$pkgver" > VERSION
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	export GIT_CEILING_DIRECTORIES="$srcdir"
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_TESTING=ON \
		-DBoost_USE_STATIC_LIBS=OFF \
		$CMAKE_CROSSOPTS .
	make -C build -j1
}

check() {
	./build/test/gitversion/gitversion-test
	./build/test/cpp-utils/cpp-utils-test
	./build/test/parallelaccessstore/parallelaccessstore-test
	./build/test/blockstore/blockstore-test
	./build/test/blobstore/blobstore-test
	./build/test/cryfs/cryfs-test
}

package() {
	make -C build PREFIX=/usr DESTDIR="$pkgdir" install
}

sha512sums="81380b8f455cc058427e638b55dcb4fcc64fc09930d897e750fb69509e8f100b048d050ec71e0acefe8a93973cf26ca4dc8dec806b905ce6d82ce78066ff01db  cryfs-0.10.3.tar.gz
d299466c8cfaa0f1f75565756d95a12cd7fa94615f0292f31ad0494dc8a0aae35c22fbab023d7e183b95e877c58553a0c8f8ab1f7444df1f9d1b292c063edfb0  0001-fix-for-python3.patch"
